package com.shujia.flink.window

import org.apache.flink.streaming.api.scala._

object Demo2COuntWindow {
  def main(args: Array[String]): Unit = {
    //创建flink的运行环境
    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment


    val ds: DataStream[String] = env.socketTextStream("master", 7777)

    /**
      * countWindow: 每几个单词统计一次
      *
      */

    ds.map((_, 1))
      .keyBy(_._1)
      .countWindow(10, 2)
      .sum(1)
      .print()


    env.execute()

  }

}
